IF OBJECT_ID('dbo.csp_rptInstantAccount_CompleteNonNIH') IS NOT NULL
BEGIN
    DROP PROCEDURE dbo.csp_rptInstantAccount_CompleteNonNIH
END
GO

CREATE PROCEDURE dbo.csp_rptInstantAccount_CompleteNonNIH
(
	@Institution varchar(50)
,	@PostAwardManager varchar(50)
,	@FromDate smalldatetime
,	@ThroughDate smalldatetime
)
AS

select distinct *,Pending = CASE WHEN DaysAttachmenttoFEAA is null THEN 'YES' ELSE '' END 
from infoedstaging.dbo.tmpInstantAccountSetup 
where (Sponsor not like 'NIH%' or InstrumentType in ('Subcontract','Contract')) 
and (Institution = @Institution OR @Institution IS NULL)
and (PostAwardManager = @PostAwardManager OR @PostAwardManager IS NULL)
and (UploadDate >= @FromDate OR @FromDate IS NULL)
and (UploadDate < DATEADD(day,1,@ThroughDate) OR @ThroughDate IS NULL)
order by UploadDate desc


GO
